package shapes;
import processing.core.*;
public class PolyCircle implements Shape{
	float r;
	int res;
	float[][] p;
	float scale = 1;
	
	public PolyCircle(float r, int res){
		this.r = r;
		this.res = res;
		calcCircle();
	}

	public void calcCircle(){
		p = new float[res][2];
		float step = 2 * (float)Math.PI / res;
		for(int i = 0; i < res; i++){
			p[i][0] = r * (float)Math.cos(step * i);
			p[i][1] = r * (float)Math.sin(step * i);
		}
	}
	
	public void draw(PApplet pa){
		pa.beginShape(PApplet.POLYGON);
		for(int i = 0; i < res; i++)
			pa.vertex(p[i][0] * scale, p[i][1] * scale, 0);
		pa.endShape();
	}

	public void scale(float s) {
		scale = s;
		
	}
	
}
